package com.ruoyi.Plancontent.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.Plancontent.mapper.StudyPlancontentMapper;
import com.ruoyi.Plancontent.domain.StudyPlancontent;
import com.ruoyi.Plancontent.service.IStudyPlancontentService;

/**
 * 复习计划存储Service业务层处理
 * 
 * @author luobom
 * @date 2021-12-10
 */
@Service
public class StudyPlancontentServiceImpl implements IStudyPlancontentService 
{
    @Autowired
    private StudyPlancontentMapper studyPlancontentMapper;

    @Override
    public int mainisnot(String createBy){
        return studyPlancontentMapper.mainisnot(String.valueOf(SecurityUtils.getUserId()));
    }

    /**
     * 查询复习计划存储
     * 
     * @param uid 复习计划存储主键
     * @return 复习计划存储
     */
    @Override
    public StudyPlancontent selectStudyPlancontentByUid(String uid)
    {
        return studyPlancontentMapper.selectStudyPlancontentByUid(uid);
    }

    /**
     * 查询复习计划存储列表
     * 
     * @param studyPlancontent 复习计划存储
     * @return 复习计划存储
     */
    @Override
    public List<StudyPlancontent> selectStudyPlancontentList(StudyPlancontent studyPlancontent)
    {
        studyPlancontent.setCreateBy(String.valueOf(SecurityUtils.getUserId()));
        return studyPlancontentMapper.selectStudyPlancontentList(studyPlancontent);
    }

    /**
     * 新增复习计划存储
     * 
     * @param studyPlancontent 复习计划存储
     * @return 结果
     */
    @Override
    public int insertStudyPlancontent(StudyPlancontent studyPlancontent)
    {
        List<StudyPlancontent> list=studyPlancontentMapper.selectStudyPlancontentList(new StudyPlancontent());
        if(list.size()>=10){return 0;}
        studyPlancontent.setCreateBy(String.valueOf(SecurityUtils.getUserId()));
        studyPlancontent.setCreateTime(DateUtils.getNowDate());
        return studyPlancontentMapper.insertStudyPlancontent(studyPlancontent);
    }

    /**
     * 修改复习计划存储
     * 
     * @param studyPlancontent 复习计划存储
     * @return 结果
     */
    @Override
    public int updateStudyPlancontent(StudyPlancontent studyPlancontent)
    {
        studyPlancontent.setCreateBy(String.valueOf(SecurityUtils.getUserId()));
        studyPlancontent.setUpdateTime(DateUtils.getNowDate());
        return studyPlancontentMapper.updateStudyPlancontent(studyPlancontent);
    }

    /**
     * 批量删除复习计划存储
     * 
     * @param uids 需要删除的复习计划存储主键
     * @return 结果
     */
    @Override
    public int deleteStudyPlancontentByUids(String[] uids)
    {
        return studyPlancontentMapper.deleteStudyPlancontentByUids(uids);
    }

    /**
     * 删除复习计划存储信息
     * 
     * @param uid 复习计划存储主键
     * @return 结果
     */
    @Override
    public int deleteStudyPlancontentByUid(String uid)
    {
        return studyPlancontentMapper.deleteStudyPlancontentByUid(uid);
    }
}
